<?php	
	ob_start();
	session_start();
	function curPageName() {
	 	return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
	}
	$_SESSION['browser']="ERP";
	$_SESSION['rows_page'] = 20;
	$_SESSION['accrows_page']=5;
	$title = $_SESSION['browser'];
	$error = $_SESSION['error'];
	$content = "content/Login_content.php";
	$handler = "handle/loginHandler.php";
	//echo $_SESSION['lang'];
	$curPageName=curPageName();
	$_SESSION['lastpage'] = "../login.php";
	
	if($_COOKIE['IDEmployee']!="")
	{
		$_SESSION['IDEmployee'] =$_COOKIE['IDEmployee'];
		include "operations/connection.php";

		$query = mysql_query("select IDEmployee,UserName,FullName,IDRole,CurrentLanguage,CAST(employee.Accountant AS unsigned integer ) AS Accountant from employee where IDEmployee='".$_SESSION['IDEmployee']."' and State=1");
		$row=mysql_fetch_assoc($query);
		$_SESSION['user'] =$row['UserName'];
		$_SESSION['fullname'] =$row['FullName'];
		$_SESSION['role'] =$row['IDRole'];
		$_SESSION['lang']=$row['CurrentLanguage'];
		$_SESSION['ketoan']=$row[Accountant];
		
		mysql_close($connection);
		
		$lang=$_SESSION['lang'];

		if($lang==''){
			$lang='EN';
			$_SESSION['lang']="EN";
		}

		header( 'Location: home.php' );
	}
	else {
		require("LoginTemplate.php");
	}
	
?>
<? ob_flush(); ?>